package com.haizhi.crm.api.controller.sys.auth;

import com.haizhi.crm.common.model.Response;
import com.haizhi.crm.sys.auth.model.PositionResourceQo;
import com.haizhi.crm.sys.auth.service.PositionPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * Created by yangyijun on 2018/5/17.
 */
@Api(description = "[系统-权限-岗位权限]-增删改查" )
@RestController
@RequestMapping("/auth/positionPermission" )
public class PositionPermissionController {

    @Autowired
    private PositionPermissionService positionPermissionService;

    @PostMapping("/save" )
    @ApiOperation(value = "设置-岗位权限管理-添加岗位权限" )
    public Response save(@RequestBody @Valid PositionResourceQo prpQo) {
        return positionPermissionService.save(prpQo);
    }

    @PostMapping("/update" )
    @ApiOperation(value = "设置-岗位权限管理-修改岗位权限" )
    public Response update(@RequestBody @Valid PositionResourceQo prpQo) {
        return positionPermissionService.update(prpQo);
    }

    @DeleteMapping("/delete" )
    @ApiOperation(value = "设置-岗位权限管理-删除岗位权限" )
    public Response delete(@RequestParam Long positionId) {
        return positionPermissionService.delete(positionId);
    }

    @GetMapping("/list" )
    @ApiOperation(value = "设置-岗位权限管理-查看岗位权限列表" )
    public Response list() {
        return positionPermissionService.list();
    }

    @GetMapping("/detail" )
    @ApiOperation(value = "设置-岗位权限管理-查看岗位权限信息", notes = "可以用在详情页或者修改页面获取岗位的详细权限信息" )
    public Response detail(@RequestParam Long positionId) {
        return positionPermissionService.detail(positionId);
    }
}
